def klk(s):
    a = []
    br = {"(" : ")", "<" : ">", "[" : "]", "{" : "}"}
 
    for c in s:
        if c in br.keys():
            a.append(c)
        elif c in br.values():
            if not a or br[a.pop()] != c:
                return False
 
    return not a
 
sequence = input()
print(klk(sequence))
